﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;


namespace Asah.Web.ViewState.Provider
{
    /// <summary>
    /// Represents the custom viewstate provider section in web.config.
    /// 
    /// The Factory Design Pattern implementation is hidden from us, but is implemented
    /// by the ConfigurationSection base class. This class reads the configuration 
    /// file (web.config) and manufactures the viewstate providers accordingly.
    /// </summary>
    public class ViewStateProviderServiceSection : ConfigurationSection
    {
        /// <summary>
        /// Gets a collection of viewstate providers from web.config.
        /// </summary>
        [ConfigurationProperty("providers")] 
        public ProviderSettingsCollection Providers
        {
            get
            {
                return (ProviderSettingsCollection) base["providers"];
            }
        }

        /// <summary>
        /// Gets or sets the default viewstate provider.
        /// </summary>
        [StringValidator(MinLength=1), ConfigurationProperty("defaultProvider", DefaultValue="ViewStateProviderCache")]
        public string DefaultProvider
        {
            get
            {
                return Convert.ToString(base["defaultProvider"]);
            }
            set
            {
                base["defaultProvider"] = value;
            }
        }
    }
}
